/**
 * 个人配置模块
 * 
 */
define(function() {
	var _config=null;
	var _self= {

		get: function(key) {
			if (window.localStorage) {
				var d= JSON.parse(window.localStorage.getItem(key));
				_config=d;
				return d;
			}
			return null;
		},

		set: function(key, value) {
			window.localStorage.setItem(key,value);
			_config=JSON.parse(value);
		},
		
		change:function(key,name,value){
			var cache=_self.get(key);
			cache.rows.forEach(function(item,index,_array){
				if(item.name==name){
					item.value=value;
				}
			});
			_self.set(key,JSON.stringify(cache));
			return cache;
		},
		
		check:function(id,value,key){
			var result=false;
			key=key||"PCFG_DATA";
			var cache=_self.get(key);
			cache.rows.some(function(item,index,_array){
				if(item.id==id && item.value==value){
					result=true;
					return true;
				}
			});
			return result;
		},
		
		query:function(id,key){
			var result="";
			key=key||"PCFG_DATA";
			var cache=_self.get(key);
			cache.rows.forEach(function(item,index,_array){
				if(item.id==id){
					result=item.value;
				}
			});
			return result;
		}
		
	}

	return _self;
})